#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int cmp(void* a, void* b)
{
	return *(int*)a < *(int*)b;
}

int jump(int* arr, int n)
{
	int left = 0;
	int right = n - 1;
	int sum = arr[0] * arr[0];
	while (left < right)
	{
		sum += (int)pow(arr[left++] - arr[right], 2);
		if (left == right)
			break;
		else
			sum += (int)pow(arr[left] - arr[right--], 2);
	}
	return sum;
}

int main()
{
	int heigh[300];
	int n = 0;
	scanf("%d", &n);
	int i = 0;
	for (i = 0; i < n; i++)
		scanf("%d", &heigh[i]);
	qsort(heigh, n, sizeof(int), cmp);
	int max_ph = jump(heigh,n);
	printf("%d", max_ph);
	return 0;
}